﻿Dcqtech_Form_Controls.ButtonTextBox = $.extend({}, Dcqtech_Form_Controls.Default);

Dcqtech_Form_Controls.ButtonTextBox.setDefaultValue = function (id, $root, fieldInfo) {
    var value = fieldInfo.defaultValue;
    let container = $root.find("[dcqtech_id='" + id + "']");
    container.parent().css("height","44px")
    container.parent().next(".control-label").addClass("file-cell-control")
    console.log("---")
    if (!value) return;
    value = template.render(value, ServerParam);
    let control = $root.find("[dcqtech_data='" + id + "']");
    control.val(value);

}
window.dcq_controlClick_buttonTextBoxView = function (btn) {
    var $root = $(btn).parent().parent();
    var id = $root.attr("dcqtech_id");
    var fInfo = Dcqtech_Form.formInfos.formInfos.fieldInfos[id];
    var openUrl = fInfo.appendProperties.appendProperties_openUrl;
    var win = self;
    if (openUrl) {
        openUrl = template.render(Dcqtech.Url.Content(openUrl), (ServerParam));
        if (fInfo.appendProperties.appendProperties_openStyle == "modal") {
            if (fInfo.appendProperties.appendProperties_okFunction) {
                parent.eModal.iframe({
                    title: fInfo.appendProperties.appendProperties_modalTitle,
                    url: openUrl,
                    buttons: [{
                        text: "确定",
                        style: 'info', close: true, click: function () {
                            win[fInfo.appendProperties.appendProperties_okFunction](top.$('.modal-content iframe')[0].contentWindow, id);
                        }
                    }]
                });
            } else {
                parent.eModal.iframe({
                    title: fInfo.appendProperties.appendProperties_modalTitle,
                    url: openUrl
                });
            }
        } else if (fInfo.appendProperties.appendProperties_openStyle == "page") {
            window.open(openUrl);
        }
    }
}

Dcqtech_Form_Controls.ButtonTextBox.setReadonly = function (id, isReadOnly) {
    if (typeof isReadOnly != "boolean") {
        isReadOnly = isReadOnly == "1";
    }
    $("[dcqtech_id='" + id + "'] button").prop("disabled", isReadOnly);
};